<?php
/**
 * @package EasyTop
 * @subpackage PlusTheme
 */

automatic_feed_links();

if ( function_exists('register_sidebar') )
	register_sidebar(array(
		'before_widget' => '<div id="%1$s" class="holder %2$s">',
		'after_widget' => '</div>',
		'before_title' => '<h2>',
		'after_title' => '</h2>',
	));


// This theme uses wp_nav_menu() in one location.
register_nav_menus( array(
	'primary' => __( 'Primary Navigation', 'twentyten' ),
) );
	
	
// This theme uses post thumbnails
add_theme_support( 'post-thumbnails' );
add_image_size('project-thumb', '999', '999', true);

function easytop_thumb_img($post_id, $width=300, $height=215) {
	$result = wp_get_attachment_image_src( get_post_thumbnail_id($post_id), '' );
	if($result) {
		$result = $result[0];
		$result = substr($result, strpos($result, '/wp-content' ));
		
		echo get_bloginfo('stylesheet_directory').'/phpthumb/phpThumb.php?src='.$result.'&amp;w='.$width.'&amp;h='.$height.'&amp;zc=1';
	} else {
		echo 'http://www.easytopltd.com/wp-content/themes/easytopplus/images/logo.png';
	}
}

// Breadcrumb Function, inspired by Hybrid Theme Framework
function easytop_breadcrumb() {
	if (is_single()) :
		$breadcrumb = '<li class="first">You Are Here</li>
		<li>&#187;</li>
		<li><a href="'.get_option('home').'">Home</a></li>
		<li>&#187;</li>';
		$categories = get_the_category(', ');
		foreach($categories as $cat) :
			$cats[] = "\n".'<li><a href="' . get_category_link($cat->term_id) . '" title="' . $cat->name . '">' . $cat->name . '</a></li>';
		endforeach;
		if($cats != NULL):
		$breadcrumb .= join(', ', $cats) . ' &raquo; ' ;		
		endif;
		$breadcrumb .= '<li class="current">'.single_post_title(false,false).'</li>' ;
	elseif (is_page()) :
		$breadcrumb = '<li class="first">You Are Here</li>
		<li>&#187;</li>
		<li><a href="'.get_option('home').'">Home</a></li>
		<li>&#187;</li>';
		$parents = array();
		global $post;
		$parent_id = $post->post_parent;
		while($parent_id) :
			$page = get_page($parent_id);
			if($params["link_none"])
				$parents[]  = get_the_title($page->ID);
			else
				$parents[]  = "\n".'<li><a href="'.get_permalink($page->ID).'" title="'.get_the_title($page->ID).'">'.get_the_title($page->ID).'</a> &raquo; </li>';
			$parent_id  = $page->post_parent;
		endwhile;
		$parents = array_reverse($parents);
		$breadcrumb .= join(' ', $parents);
		$breadcrumb .= "\n".'<li class="current">'.get_the_title().'</li>' ;
	elseif (is_category()) :
		$breadcrumb = '<li class="first">You Are Here</li>
		<li>&#187;</li>
		<li><a href="'.get_option('home').'">Home</a></li>
		<li>&#187;</li>';
		$cat = intval( get_query_var('cat') );
		$parent = &get_category($cat);
		if(is_wp_error($parent))
			$parents = false;
		if($parent->parent && ($parent->parent != $parent->term_id) )
			$parents = get_category_parents($parent->parent, true, $separator, false);
		if($parents) $breadcrumb .= $parents . ' &raquo; ' ;
		$breadcrumb .= single_cat_title(false,false);
	elseif(is_tag()) :
		$breadcrumb = '<li class="first">You Are Here</li>
		<li>&#187;</li>
		<li><a href="'.get_option('home').'">Home</a></li>
		<li>&#187;</li>';
		$breadcrumb .= 'Tag: ' . single_tag_title(false,false) ;
	elseif(is_author()) :
		$breadcrumb = '<li class="first">You Are Here</li>
		<li>&#187;</li>
		<li><a href="'.get_option('home').'">Home</a></li>
		<li>&#187;</li>';
		$breadcrumb .= 'Author: ' . wp_title(false,false,false) ;
	elseif(is_search()) :
		$breadcrumb = '<li class="first">You Are Here</li>
		<li>&#187;</li>
		<li><a href="'.get_option('home').'">Home</a></li>
		<li>&#187;</li>';
		$breadcrumb .= 'Search results for &quot;' . attribute_escape(get_search_query()) . '&quot;';
	elseif(is_day()) :
		$breadcrumb = '<li class="first">You Are Here</li>
		<li>&#187;</li>
		<li><a href="'.get_option('home').'">Home</a></li>
		<li>&#187;</li>';
		$breadcrumb .= '<a href="' . get_year_link(get_the_time('Y')) . '" title="' . get_the_time('Y') . '">' . get_the_time('Y') . '</a> &raquo; ';
		$breadcrumb .= '<a href="' . get_month_link(get_the_time('Y'), get_the_time('m')) . '" title="' . get_the_time('F') . '">' . get_the_time('F') . '</a> &raquo; ';
		$breadcrumb .= get_the_time('j') ;
	elseif(is_month()) :
		$breadcrumb = '<li class="first">You Are Here</li>
		<li>&#187;</li>
		<li><a href="'.get_option('home').'">Home</a></li>
		<li>&#187;</li>';
		$breadcrumb .= '<a href="' . get_year_link(get_the_time('Y')) . '" title="' . get_the_time('Y') . '">' . get_the_time('Y') . '</a> &raquo; ';
		$breadcrumb .= get_the_time('F') ;
	elseif(is_year()) :
		$breadcrumb = '<li class="first">You Are Here</li>
		<li>&#187;</li>
		<li><a href="'.get_option('home').'">Home</a></li>
		<li>&#187;</li>';
		$breadcrumb .= get_the_time('Y');
	elseif(is_404()) :
		$breadcrumb = '<li class="first">You Are Here</li>
		<li>&#187;</li>
		<li><a href="'.get_option('home').'">Home</a></li>
		<li>&#187;</li>';
		$breadcrumb .= '404 Not Found';
	else :
		$breadcrumb = '<li class="first">You Are Here</li>
		<li>&#187;</li>
		<li><a href="'.get_option('home').'">Home</a></li>
		<li>&#187;</li>';
		$breadcrumb .= get_option('blogname');
	endif;
	return $breadcrumb;
}
	
?>
